<template>
  <div class="login-container">
    <vue-particles
      color="#fff"
      :particle-opacity="0.7"
      :particles-number="50"
      shape-type="circle"
      :particle-size="4"
      lines-color="#fff"
      :lines-width="1"
      :line-linked="true"
      :line-opacity="0.4"
      :lines-distance="150"
      :move-speed="2"
      :hover-effect="true"
      hover-mode="grab"
      :click-effect="true"
      click-mode="push"
      class="lizi"
    />
    <img src="~@/assets/images/tu.png" alt="" class="boximg" />
    <el-form
      ref="loginForm"
      :model="loginForm"
      :rules="loginRules"
      class="login-form"
      auto-complete="on"
      label-position="left"
    >
      <div class="title-container">
        <h3 class="title">
          <i class="el-icon-user" />
          <span>登录</span>
        </h3>
      </div>
      <div class="input-box">
        <el-form-item prop="username">
          <el-input
            placeholder="用户名"
            auto-complete="new-password"
            prefix-icon="el-icon-user-solid"
            v-model="loginForm.username"
          >
          </el-input>
        </el-form-item>

        <el-form-item prop="password">
          <el-input
            v-model="loginForm.password"
            auto-complete="new-password"
            prefix-icon="el-icon-lock"
            @keyup.enter.native="handleLogin"
          />
        </el-form-item>
        <el-form-item style="margin-top: 0.5rem">
          <el-button
            :loading="loading"
            type="primary"
            @click.native.prevent="handleLogin"
            >登录</el-button
          >
        </el-form-item>
      </div>
    </el-form>
  </div>
</template>

<script>
import { login } from "@/api/index.js";
export default {
  name: "Login",
  data() {
    return {
      loginForm: {
        username: "admin",
        password: "111111"
      },
      loginRules: {
        username: [{ required: true, trigger: "blur", message: "请输入账号" }],
        password: [{ required: true, trigger: "blur", message: "请输入密码" }]
      },
      loading: false,
      passwordType: "password"
    };
  },
  watch: {},
  methods: {
    handleLogin() {
      this.$refs.loginForm.validate(valid => {
        if (valid) {
          this.$router.push({ path: "/yunzhi" });
          console.log(this.loginForm, 99);
          // login({
          //   apiKey: "tM35Nv955e8e321fac2d318751c8b57ccfd9ed9818003f6",
          //   pageSize: 10
          // }).then(res => {
          //   console.log(res, 785);
          // });
        }
      });
    }
  }
};
</script>

<style lang="stylus" scoped>
.login-container {
  min-height: 100%;
  width: 100%;
  background: linear-gradient(
    180deg,
    #1e202d 0%,
    #1a2465 56.99%,
    #10121a 100%
  );
  overflow: hidden;
  display: flex;
  justify-content: center;
  align-items: center;

  .lizi {
    width: 100%;
    height: 100%;
    position: absolute;
    left: 0;
    right: 0;
    top: 0;
    bottom: 0;
  }

  .boximg {
    position: relative;
    z-index: 111;
  }

  .login-form {
    position: relative;
    z-index: 111;
    width: 4.8rem;
    height: 3.7rem;
    background: #2c304c;
    border-radius: 2px;
  }

  .tips {
    font-size: 0.14rem;
    color: #fff;
    margin-bottom: 0.1rem;

    span {
      &:first-of-type {
        margin-right: 0.16rem;
      }
    }
  }

  .svg-container {
    padding: 6px 5px 6px 15px;
    color: #889aa4;
    vertical-align: middle;
    width: 0.3rem;
    display: inline-block;
  }

  .title-container {
    height: 0.4rem;
    line-height: 0.4rem;
    background: #52566e;
    overflow: hidden;

    .title {
      i {
        margin-left: 0.15rem;
      }

      span {
        margin-left: 0.08rem;
      }

      font-size: 0.14rem;
      color: #fff;
      line-height: 0.4rem;
      margin: 0;
      font-weight: 500;
    }
  }

  .input-box {
    width: 3rem;
    margin: 0.6rem auto 0;

    .el-button {
      width: 100%;
      margin-bottom: 0.5rem;
    }
  }

  .show-pwd {
    position: absolute;
    right: 10px;
    top: 0.07rem;
    font-size: 0.16rem;
    color: #889aa4;
    cursor: pointer;
    user-select: none;
  }
}
</style>
